package com.kgc.personprovider.controller;

import com.kgc.basic.util.ResponseMsg;
import com.kgc.personcommon.pojo.Department;
import com.kgc.personcommon.remote.DeptRemote;
import com.kgc.personprovider.service.DeptService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.util.Map;
@Controller
public class DeptController implements DeptRemote {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private DeptService deptService;

    @Override
    public ResponseMsg getDeptPage(Map<String, Object> map) {
        logger.info("DeptController.getDeptPage map={}", map);
        ResponseMsg responseMsg = deptService.getByPage(map);
        logger.debug("deptService.getByPage responseMsg={}", responseMsg+"map="+map);
        return responseMsg;
    }

    @Override
    public ResponseMsg addDept(Department department) {
        logger.info("DeptController.addDept department={}", department);
        ResponseMsg responseMsg = deptService.add(department);
        logger.debug("deptService.addDept responseMsg={}", responseMsg+"department="+department);
        return responseMsg;
    }

    @Override
    public ResponseMsg updateDept(Department department) {
        logger.info("DeptController.updateDept department={}", department);
        ResponseMsg responseMsg = deptService.update(department);
        logger.debug("deptService.updateDept responseMsg={}", responseMsg+"department="+department);
        return responseMsg;
    }

    @Override
    public ResponseMsg delDept(String id) {
       logger.info("DeptController.delDept id={}", id);
       ResponseMsg responseMsg = deptService.delete(id);
       logger.debug("deptService.delDept responseMsg={}", responseMsg+"id="+id);
       return responseMsg;
    }

    @Override
    public ResponseMsg getDeptById(String id) {
        logger.info("DeptController.getDeptById id={}", id);
        ResponseMsg responseMsg = deptService.getById(id);
        logger.debug("deptService.getById responseMsg={}", responseMsg+"id="+id);
        return responseMsg;
    }


    @Override
    public ResponseMsg getAllDept(Map<String, Object> map) {
        logger.info("DeptController.getAllBOM");
        ResponseMsg responseMsg = deptService.getAll(map);
        logger.debug("deptService.getAllBOM responseMsg={}", responseMsg+"map="+map);
        return responseMsg;
    }
}
